package frontend.login.controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ActionContext;

import core.profile.model.BasicProfile;

import frontend.registration.dao.RegisterDao;
import frontend.user.controller.GetDataByEmailId;



import java.util.*;

public class OwnerLoginAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 118112323324238757L;
	private String userId;
	private String password;
	private String errorMsg ;
	private RegisterDao registerdao=new RegisterDao();
	public String execute() throws Exception{

		if (registerdao.getOwnerUser(userId,password)) {
			BasicProfile bp = GetDataByEmailId.getBasicProfileByEmailId(userId);
			Map<String, Object> session = ActionContext.getContext().getSession();
			session.put("bp",bp);
			session.put("logined","true");
			session.put("uuid", bp.getUuid());
			session.put("emailId", userId);
            return SUCCESS;
        }
		else{
			this.setErrorMsg("Username or password does not match.");
			 return ERROR;
		}
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}


}